home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1085 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  124 lines

  1. Path: opalo.etsiig.uniovi.es!soneto!u1436956
  2. Newsgroups: comp.lang.c
  3. Subject: Problem in my INT 16H!!!
  4. Message-ID: <1996Jan11.112500.5877@opalo.etsiig.uniovi.es>
  5. From: u1436956@soneto.etsiig.uniovi.es (FERNANDEZ CASTA#O ; JOSE IGNACIO)
  6. Date: 11 Jan 96 11:24:59 +0100
  7. Nntp-Posting-Host: soneto.etsiig.uniovi.es
  8. X-Newsreader: TIN [version 1.2 PL2]
  9.  
  10.  
  11.  
  12.        WHAT IS THE PROBLEM???
  13.  
  14.  
  15. #include <stdio.h>
  16. #include <dos.h>
  17. #include <conio.h>
  18. #include <stdlib.h>
  19.  
  20. #define INTR 0X16 // 22
  21.  
  22. #ifdef __cplusplus
  23.     #define __CPPARGS ...
  24. #else
  25.     #define __CPPARGS
  26. #endif
  27.  
  28. #include <stdio.h>
  29. #include <dos.h>
  30. #include <conio.h>
  31. #include <stdlib.h>
  32.  
  33. #define INTR 0X16 // 22
  34.  
  35. #ifdef __cplusplus
  36.     #define __CPPARGS ...
  37. #else
  38.     #define __CPPARGS
  39. #endif
  40.  
  41. void interrupt far ( *old_16h)(__CPPARGS);
  42.  
  43. void interrupt far new_16h(__CPPARGS)
  44. {
  45.   disable();
  46.   unsigned far *start=(unsigned far *)0x00400080;
  47.   unsigned far *end=(unsigned far *)0x00400082;       
  48.   unsigned far *head=(unsigned far *)0x0040001A;  
  49.   unsigned far *tail=(unsigned far *)0x0040001C;
  50.  
  51.   // ONLY FUNCTION 0 and 10H
  52.   asm {
  53.    cmp ah,0
  54.    je captura
  55.    cmp ah,10h
  56.    je captura
  57.   }
  58.  
  59.   /* llamamos a la vieja rutina */
  60.    enable();
  61.    old_16h();
  62.    return;
  63.  
  64.   // tratamiento de la función capturada
  65.   captura:
  66.  
  67.   // WHILE NO PRESSET NEVER KEY
  68.   while( *tail == *head );
  69.  
  70.   char far *base=(char far *)0x00400000;
  71.   char ascci=*( base + *head );
  72.   char scanCode=*( base+1 + *head );
  73.   unsigned _out=ascci*256+scanCode;
  74.  
  75.   // Incrementamos la cabeza
  76.   *head+=sizeof(unsigned);
  77.  
  78.   // Observamos si llegamos al final del buffer
  79.   if( *head >= *end)
  80.     *head = *start;
  81.  
  82.   asm {
  83.     mov ax,_out
  84.   }
  85.   enable();
  86. }
  87.  
  88. main()
  89. {
  90.   /* salvamos el vector de interrupción */
  91.    old_16h = getvect(INTR);
  92.  
  93.   /* instalamos la nueva interrupción */
  94.    setvect(INTR, new_16h);
  95.  
  96.   /* cargamos el command.com */
  97. //   system("\command.com"); // PROBLEM
  98. //      OR
  99. //   delay(6000);  // NO PROBLEM; VERY WELL 
  100. //      OR
  101.    char s[80];  // PROBLEM
  102.    gets(s);
  103.    printf("%s",s);
  104.  
  105.    printf("END 16H");
  106.  
  107.   /* restauramos el vector 16h a su valor inicial */
  108.    setvect(INTR, old_16h);
  109.  
  110.   return 0;
  111. }
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.       -   NATXO  -
  120.  
  121.  
  122.  
  123.  
  124.